package com.yu.crm.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yu.crm.domain.pojo.CrmUser;
import com.yu.crm.domain.pojo.CrmUserRole;
import com.yu.crm.service.CrmUserRoleService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * <p>
 * 用户角色表 前端控制器
 * </p>
 *
 * @author donnie-bin
 * @since 2019-06-10
 */

@Api(tags = "用户权限管理")
@RestController
@RequestMapping("/crm-user-role")
public class CrmUserRoleController {

    @Autowired
    CrmUserRoleService userRoleService;

    @ApiOperation(value = "批量保存")
    @PostMapping(value = "/save-batch")
    public void saveBatch(@RequestBody List<CrmUserRole> entityList){
        userRoleService.saveBatch(entityList);
    }

    @ApiOperation(value = "批量删除")
    @DeleteMapping(value = "/remove-batch")
    public void removeBatch(@RequestBody List<CrmUserRole> entityList){
        userRoleService.removeBatch(entityList);
    }

    @ApiOperation(value = "根据角色ID查询用户列表")
    @GetMapping(value = "/list-user-by-role-id")
    public IPage<CrmUser> listUserByRoleId(Page<CrmUser> page, Long roleId,String condition) {
        return userRoleService.listUserByRoleId(page, roleId,condition);
    }
}

